package licode.unisop.types.dp;

import org.springframework.util.Assert;

/**
 * 平台状态定义
 *
 * @author licode
 */
public class PlatformState {

    public static final PlatformState NO_ACTIVATE = new PlatformState(0);
    public static final PlatformState ACTIVATED = new PlatformState(1);
    public static final PlatformState STOPPED = new PlatformState(2);

    private final Integer state;

    private PlatformState(int state) {
        this.state = state;
    }

    public static PlatformState build(int state) {
        if (NO_ACTIVATE.state == state) {
            return NO_ACTIVATE;
        } else if (ACTIVATED.state == state) {
            return ACTIVATED;
        } else if (STOPPED.state == state) {
            return STOPPED;
        }

        Assert.isTrue(false,"非法的平台状态：" + state);
        return new PlatformState(state);
    }

    public boolean isActive() {
        return ACTIVATED.state.equals(state);
    }

    public boolean isStopped() {
        return STOPPED.state.equals(state);
    }

    public Integer getState() {
        return state;
    }
}
